package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.JsonUser;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Json参数的接收
 * @author stone
 * @date 2021/12/31 15:05
 */
@RestController
@RequestMapping("json")
public class JsonController {


    //{"username":"admin123","password":"admin123"}
    @RequestMapping("login")
    //public BaseRespVo login(JsonUser user) {//localhost:8080/json/login?username=admin123&password=admin123
    public BaseRespVo login(@RequestBody JsonUser user) {
        int age = user.getAge();
        return BaseRespVo.ok();
    }

    @RequestMapping("login2")
    public BaseRespVo login2(@RequestBody Map user) {
        Object age = user.get("age");
        //age究竟是什么类型呢？
        return BaseRespVo.ok();
    }
}
